function initailize_member_list() {
    var teacherName = top.document.getElementById("userName").text;
    var obj = new Object();
    obj.teacherName = teacherName;
    $.ajax({
        url: "/get_student_user_list",
        type: "POST",
        data:obj,
        cache: false,//设置不缓存
        success: initailize_member_list_success,
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            if (XMLHttpRequest.status >= 400 && XMLHttpRequest.status < 500) {
                alert("客户端请求出错！错误代码（" + XMLHttpRequest.status + "," + XMLHttpRequest.readyState + "," + textStatus + "）");
            } else {
                if (XMLHttpRequest.status >= 500 || XMLHttpRequest.status <= 600) {
                    alert("服务器出错！错误代码（" + XMLHttpRequest.status + "," + XMLHttpRequest.readyState + "," + textStatus + "）");
                } else {
                    if (XMLHttpRequest.status >= 300 || XMLHttpRequest.status < 400) {
                        alert("重定向问题！错误代码（" + XMLHttpRequest.status + "," + XMLHttpRequest.readyState + "," + textStatus + "）");
                    } else {
                        alert("抱歉，系统好像出现一些异常！错误代码（" + XMLHttpRequest.status + "," + XMLHttpRequest.readyState + "," + textStatus + "）");
                    }
                }
            }
        }
    });
}

function initailize_member_list_success(data) {
    var dom = document.getElementById("member-list");
    var str = "";
    for(var i=0;i<data.length;i++){
        str += "<tr>" +
            "<td>" +
            "<div class=\"layui-unselect layui-form-checkbox\" lay-skin=\"primary\" data-id='2'><i class=\"layui-icon\">&#xe605;</i></div>" +
            "</td>" +
            "<td>"+ data[i].studentId +"</td>" +
            "<td>"+ data[i].studentName +"</td>" +
            "<td>"+ data[i].tel +"</td>" +
            "<td>"+ (data[i].timestamp).replace("T0"," ").split(".")[0] +"</td>" +
            " <td class=\"td-manage\">" +
            "<a title=\"编辑\"  onclick=\"x_admin_show('编辑','member-edit.html',600,400)\" href=\"javascript:;\">" +
            "<i class=\"layui-icon\">&#xe642;</i>" +
            "</a>" +
            "<a onclick=\"x_admin_show('修改密码','member-password.html',600,400)\" title=\"修改密码\" href=\"javascript:;\">" +
            "<i class=\"layui-icon\">&#xe631;</i>" +
            "</a>" +
            "<a title=\"删除\" onclick=\"member_del(this,"+ data[i].studentId +")\" href=\"javascript:;\">" +
            "<i class=\"layui-icon\">&#xe640;</i>" +
            " </a>" +
            "</td>" +
            "</tr>"
    }
    dom.innerHTML = str;
}

function get_container_information() {
    $.ajax({
        url:"/get_container_information",
        method:"GET",
        cache: false,//设置不缓存
        success: get_container_information_sucess,
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            if (XMLHttpRequest.status >= 400 && XMLHttpRequest.status < 500) {
                alert("客户端请求出错！错误代码（" + XMLHttpRequest.status + "," + XMLHttpRequest.readyState + "," + textStatus + "）");
            } else {
                if (XMLHttpRequest.status >= 500 || XMLHttpRequest.status <= 600) {
                    alert("服务器出错！错误代码（" + XMLHttpRequest.status + "," + XMLHttpRequest.readyState + "," + textStatus + "）");
                } else {
                    if (XMLHttpRequest.status >= 300 || XMLHttpRequest.status < 400) {
                        alert("重定向问题！错误代码（" + XMLHttpRequest.status + "," + XMLHttpRequest.readyState + "," + textStatus + "）");
                    } else {
                        alert("抱歉，系统好像出现一些异常！错误代码（" + XMLHttpRequest.status + "," + XMLHttpRequest.readyState + "," + textStatus + "）");
                    }
                }
            }
        }
    });
}

function get_container_information_sucess(data) {
    data = JSON.parse(data)
    var str = "";

    for (var i=0;i<data.length;i++) {
        str += "<tr>" +
            "<td>" +
            "<div class=\"layui-unselect layui-form-checkbox\" lay-skin=\"primary\" data-id='2'><i class=\"layui-icon\">&#xe605;</i></div>" +
            "</td>" +
            "<td>"+ data[i].Id.substring(0,9)+"..."+"</td>" +
            "<td>"+ data[i].Names+"</td>" +
            "<td>"+ data[i].State +"</td>" +
            "<td>"+ data[i].ImageID.substring(0,15)+"..." +"</td>" +
            "<td>"+ data[i].Image +"</td>" +
            "<td>"+ data[i].Status +"</td>" +
            "<td class=\"td-manage\">" +
            "<a title=\"删除\" onclick=\"member_del(this,"+ data[i].Id + ")\" href=\"javascript:;\">" +
            "<i class=\"layui-icon\">&#xe640;</i>" +
            "</a>" +
            "</td>" +
            "</tr>";
    }

    document.getElementById("container-table").innerHTML = str;
    document.getElementById("data-message").innerText = "共有数据: "+ data.length+"条";

}